package com.zero.mxshengadmin.modules.website.controller;

import com.zero.mxshengadmin.common.utils.R;
import com.zero.mxshengadmin.modules.website.entity.WebsiteAdvertiseEntity;
import com.zero.mxshengadmin.modules.website.entity.WebsiteCompanyInfoEntity;
import com.zero.mxshengadmin.modules.website.service.WebsiteCompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by aicaikeji on 2019/4/3.
 */

@RestController
public class WebsiteCompanyInfoController {
    @Autowired
    private WebsiteCompanyInfoService websiteCompanyInfoService;
    /**
     * 添加公司信息
     * @param entity
     * @return
     */
    @PostMapping("/website/companyInfo/add")
    public R save(@RequestBody WebsiteCompanyInfoEntity entity) {
        websiteCompanyInfoService.save(entity);
        return R.ok();
    }

    /**
     * 删除公司信息
     * @param ids
     * @return
     */
    @PostMapping("/website/companyInfo/delete")
    public R delete(@RequestBody Long[] ids) {
        websiteCompanyInfoService.removeByIds(ids);
        return R.ok();
    }

    /**
     * 更新公司信息
     * @param entity
     * @return
     */
    @PostMapping("/website/companyInfo/update")
    public R update(@RequestBody WebsiteCompanyInfoEntity entity) {
        websiteCompanyInfoService.update(entity);
        return R.ok();
    }

    /**
     * 查询某条公司信息
     * @param id
     * @return
     */
    @GetMapping("/website/companyInfo/find/{id}")
    public R find(@PathVariable("id") Long id) {
        WebsiteCompanyInfoEntity entity = websiteCompanyInfoService.getById(id);
        return R.ok().put("result",entity);
    }

    /**
     * 查询一条公司的信息
     * @return
     */
    @GetMapping("/website/companyInfo/select")
    public R find() {
        WebsiteCompanyInfoEntity entity = websiteCompanyInfoService.getOneItem();
        return R.ok().put("result",entity);
    }

}
